﻿
Imports System.Object
Imports VSModel
Imports Cls_Common
Partial Class FrontEnd_Control_Store_Index
    Inherits System.Web.UI.UserControl
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not Page.IsPostBack Then


            If Not Page.RouteData.Values("Id") Is Nothing Then
                LoadData(Page.RouteData.Values("Id"))

            End If
        End If
    End Sub
    Private Sub LoadData(ByVal StoreId As Integer)
        Using Data As New VSEntities
            Dim p = (From q In Data.Products Where q.StoreId = StoreId And q.StatusId = 3 And q.PublishedDate <= Now() And (q.eEffectiveDate >= Now() Or q.eEffectiveDate Is Nothing) Order By q.PublishedDate Descending Select q).Take(16).ToList

            With rptProduct
                .datasource = p
                .databind()
            End With

        End Using
    End Sub

    Protected Sub rtpProduct_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.RepeaterItemEventArgs) Handles rptProduct.ItemDataBound
        Dim row As VSModel.Product = CType(e.Item.DataItem, VSModel.Product)

        'Dim hplTitle As HyperLink = CType(e.Item.FindControl("hplTitle"), HyperLink)
        'hplTitle.Text = row.Title
        'hplTitle.NavigateUrl = MainDomain & row.Store.QueryString & "-" & row.StoreId & "/" & row.QueryString & "-" & row.ProductId.ToString & "/chi-tiet.html"
        'Dim imgProduct As Image = CType(e.Item.FindControl("imgProduct"), Image)

        'imgProduct.ImageUrl = CookedImageURL("140-120", row.ImagePreview.ToString)

        'Dim lblPrice As Label = CType(e.Item.FindControl("lblPrice"), Label)
        'lblPrice.Text = Format_Currency(row.SellPrice) & " vnđ"


    End Sub
End Class
